<layout name="../../../Resource/master"/>
<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
    <li><a href="index.html"><i class="fa fa-home"></i> Home</a></li>
    <li><a href="#">添加商品分类</a></li>
</ul>
<div class="m-b-md">
    <h3 class="m-b-none">添加商品分类</h3>
</div>
<div class="row">
    <div class="col-sm-12">
        <section class="panel panel-default">
            <header class="panel-heading font-bold">添加商品类型</header>
            <div class="panel-body">

                <form action="{:U('Common/sort')}" method="post">
                    <div class="container-fluid">
                        <div class="row-fluid">
                            <div class="span12">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>
                                            分类ID
                                        </th>
                                        <th>
                                            分类名称
                                        </th>
                                        <th>
                                            排序
                                        </th>
                                        <th>
                                            操作
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <foreach name='cateModelData' item='v'>
                                        <tr class="info" pid='{$v.pid}'>
                                        <td>
                                            {$v.cid}
                                        </td>
                                        <td class='open' cid='{$v.cid}'>
                                            {$v._cname}</td>
                                        </td>
                                        <td>
                                            <input type="text" name='{$v.cid}' value='{$v.sort}'/>
                                        </td>
                                        <td>
                                            <a href="{:U('Category/addSonCate', ['cid' => $v['cid']])}" class="btn btn-success"><i class="icon-edit icon-white"></i>添加子分类</a>
                                            <a href="{:U('Category/cateEdit', ['cid' => $v['cid']])}" class="btn btn-warning"><i class="icon-pencil icon-white"></i>修改</a>
                                            <a href="{:U('Category/cateDel', ['cid' => $v['cid']])}" class="btn btn-danger"><i class="icon-trash icon-white"></i>删除</a>
                                        </td>
                                        </tr>
                                    </foreach>
                                    <tr>
                                        <td colspan='4' align='center'>
                                            <input type="hidden" name='table' value='category' />
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <input type="submit" value='排序' class="btn btn-primary"/>
                        </div>
                    </div>
                </form>

            </div>
        </section>
    </div>
</div>

<script type="text/javascript">
    $(function(){
        $('.open').toggle(function(){
            var cid = $(this).attr('cid');
            $('tr[pid=' + cid + ']').fadeIn(600);
        }, function(){
            var cid = $(this).attr('cid');
            $('tr[pid=' + cid + ']').fadeOut(600);
        });
    });
</script>
